<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php echo $commander->getListCommandsPanel('sa-a-d-pager-filter', ''); ?>
<?php $countries = $shop->getCountryList(); ?>
<div class="menu_list">
	<table style="clear:both;" id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
        <thead class="fields">
            <tr>
                <th class="first center">&nbsp;&nbsp;Id&nbsp;&nbsp;</th>
                <th class="center"><?php echo ucfirst($txt->getWord('choose')); ?></th>
                <th><?php echo ucfirst($txt->getWord('name')); ?></th>
                <th><?php echo ucfirst($txt->getWord('import').' '.$txt->getWord('name')); ?></th>
                <th><?php echo ucfirst($txt->getWord('country')); ?></th>
                <th><?php echo ucfirst($txt->getWord('city')); ?></th>
                <th><?php echo ucfirst($txt->getWord('zip')); ?></th>
                <th><?php echo ucfirst($txt->getWord('e-mail')); ?></th>
                <th><?php echo ucfirst($txt->getWord('phone')); ?></th>
                <th><?php echo ucfirst($txt->getWord('active')); ?></th>
                <th><?php echo ucfirst($txt->getWord('edit')); ?></th>
                <th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
            </tr>
            <tr class="items">
	            <td class="first center"><img 	title="<?php echo ucfirst($txt->getWord('new')); ?>"
                                                class="icon command" 
                                                src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                                                onclick="if(document.getElementById('new_item_title').value != '') { edit_form.submit(); }" /></td>
	            <td class="center"><input title="<?php echo ucfirst($txt->getWord('all')); ?>" class="select_all" type="checkbox" name="select_all" value="" /></td>
	            <td><input class="small" name="new_provider_title" type="text" value="" maxlength="80" id="new_item_title" /></td>
                <td><input class="xsmall" name="new_provider_title_import" type="text" value="" maxlength="50" /></td>
                <td>
                	<select class="small" name="new_provider_country" >
                        <?php 
                        if($countries)
                        {
                            foreach($countries as $country)
                            { echo '<option value="'.$country['iso'].'" '.getIsSelectedHTML(COUNTRY, $country['iso']).'>'.$country['printable_name'].'</option>'; }
                        }
                        ?>
                    </select>
                </td>
                <td><input class="small" name="new_provider_city" type="text" value="" maxlength="80" /></td>
	            <td colspan="5">&nbsp;</td>
	            <td class="last"></td>
	        </tr>
        </thead>
        <tbody><?php echo $commander->getComponentListLoading(); ?></tbody>
    </table>
    <input type="hidden" name="del_provider_id" id="del_provider_id" value="0" />
</div>
<script type="text/javascript">
function deleteDialog(itemId)
{
	jQuery('#delete_dialog').dialog('open');
	jQuery('#delete_dialog').dialog({
		bgiframe: true,
		resizable: false,
		height:140,
		modal: true,
		overlay: 
		{
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: 
		{
			'<?php echo ucfirst($txt->getWord('no')); ?>': function() 
			{
				jQuery(this).dialog('close');
			},
			'<?php echo ucfirst($txt->getWord('delete')).' '.$txt->getWord('element'); ?>': function() 
			{
				jQuery('#del_provider_id').val(itemId);
				jQuery(this).dialog('close');
				jQuery('#edit_form').submit();
			}
		}
	});
}

jQuery(document).ready(function() 
{
	jQuery.ajax(
	{
		url: "ajax.php?con=<?php echo $_GET['con']; ?>&m=<?php echo $_GET['m']; ?>&editor=list&list=provider",
		cache: false,
	  	success: function(html)
	  	{ 
			jQuery('table.item_list tr.loading').remove();
			jQuery("table.item_list tbody").append(html); 
			jQuery("#menulist").addClass('tablesorter');
			jQuery("#menulist").tablesorter(
				{
					widthFixed: true,  
					headers: { 0: { sorter: 'numeric' }, 1: { sorter: false}, 5: {sorter: false}, 10: {sorter: false}, 11: {sorter: false} }, 
					<?php if ($_REQUEST['new_provider_title'] != ''): ?>
					sortList: [[0,1]],
					<?php else: ?>
					sortList: [[2,0]],
					<?php endif; ?>
					textExtraction: function(node) { return node.innerHTML; }
				}).tablesorterPager(
				{
					container: jQuery("div.pager")
				}).tablesorterFilter(
				{
					filterContainer: $("#filter-box"),
					filterClearContainer: $("#filter-clear-button"),
					filterWaitTime: 100,
					filterColumns: [1],
					filterCaseSensitive: false
				});
			jQuery('table.item_list tr.loading').remove();
		}
	});
});
</script>
<div id="delete_dialog" title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('provider')); ?>?" style="display:none; text-align:left;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo ucfirst($txt->getWord('sure_you_want_to_delete')); ?></p>
</div>